<template>
  <div class="container">
    <ul class="middle">
      <li
        class="middle-item"
        v-for="(item, index) in contentList"
        :key="index"
        @click="toPage(item.name)"
      >
        <img class="item-img" :src="item.img" alt="" />
        <p>{{ item.title }}</p>
      </li>
    </ul>
    <div class="title">
      <p>宜居管家</p>
      <p>宜居专享服务</p>
    </div>
    <ul class="end">
      <li
        v-for="(item, index) in endList"
        :key="index"
        @click="toPage(item.name)"
      >
        <img class="item-img" :src="item.img" alt="" />
        <p>{{ item.title }}</p>
      </li>
    </ul>
  </div>
</template>

<script>
import api from "../../api";
export default {
  name: "Category",
  data() {
    return {
      contentList: [],
      endList: [],
    };
  },
  mounted() {
    api.getMineList().then((res) => {
      // console.log(res.data);
      if (res.data.data) {
        this.contentList = res.data.data.list1;
        this.endList = res.data.data.list2;
      }
    });
  },
  methods: {
    //路由跳转
    toPage(name) {
      this.$router.push({ name });
    },
  },
};
</script>

<style scoped lang="less">
.container {
  width: 100%;
  box-sizing: border-box;
  padding: 0.2rem;
  .middle {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    padding: 0 0.2rem;
    box-sizing: border-box;
    box-shadow: 0 2px 2px #ccc;
    .middle-item {
      width: 25%;
      padding: 0.2rem 0;
      font-size: 16px;
    }
  }
  .item-img {
    width: .8rem;
    height: .8rem;
    margin-bottom: 0.1rem;
  }
  .title {
    display: flex;
    margin: 10px 0;
    & > p:first-child {
      margin: 0 0.4rem;
      font-size: 0.4rem;
    }
    & > p:last-child {
      margin-top: 0.15rem;
      font-size: 0.3rem;
    }
  }
  .end {
    width: 100%;
    padding: 0.2rem;
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    box-shadow: 0 1px 7px #ccc;
    li {
      width: 33.3%;
      margin: 0.5rem 0;
      font-size: 0.25rem;
    }
  }
}
</style>
